﻿/**
 * @file   FITKAbaqusAdaptorTransform.h
 * @brief 局部坐标系 适配器
 * @author liuzhonghua (liuzhonghuaszch@163.com)
 * @date 2024-05-27
 */
#ifndef __FITKABAQUSADAPTORTRANSFORM__H__
#define __FITKABAQUSADAPTORTRANSFORM__H__

#include "FITKAbaqusAbstractAdaptor.h"
#include "FITK_Kernel/FITKAdaptor/FITKIOAdaptorFactory.h"
#include <QHash>
 //前置声明
ForwardDeclarNS(AbaqusData, FITKDataCase)
ForwardDeclarNS(Interface, FITKAbaTransform)
ForwardDeclarNS(Interface, FITKCoordinateSystem)
ForwardDeclarNS(Interface, FITKAbaMaterialOrientationManager)
ForwardDeclarNS(Interface, FITKCoordinateSystemManager)
ForwardDeclarNS(Interface, FITKAbaMaterialOrientation)
ForwardDeclarNS(Interface, FITKAbstractModel)

namespace IO
{

    /**
     * @brief 局部坐标系 适配器
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date 2024-05-28
     */
    class FITKAbaqusAdaptorTransform : public FITKAbaqusAbstractAdaptor
    {
    public:
        explicit FITKAbaqusAdaptorTransform() = default;
        ~FITKAbaqusAdaptorTransform() = default;

        /**
         * @brief 获取适配器数据类型名
         * @return 适配器数据类型名
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-05-28
         */
        QString getAdaptorClass() override;

        /**
         * @brief 适配器读取
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date  2024-05-28
         */
        bool adaptR() override;

        /**
         * @brief 适配器写出
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date  2024-05-28
         */
        bool adaptW() override;
        /**
         * @brief 设置模型数据part-Assembly 用于模型里的局部坐标系读写
         * @param[i] modelData 模型数据
         * @param[i] caseData 模型数据
         * @param[i] writeMaterialOrientation 是否写出材料指派方向（仅在写时生效）
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-22
         */
        void setModelDataCaseData(Interface::FITKAbstractModel* modelData, AbaqusData::FITKDataCase* caseData, bool writeMaterialOrientation = false);
        /**
         * @brief 是否是全局坐标系
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-07
         */
        bool isGlobalCsys();

    private:
        /**
         * @brief 读取Transform局部坐标系
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-05-28
         */
        bool readTransform();
        /**
         * @brief 读取Orientation数据创建Transform局部坐标系
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-07
         */
        bool readOrientation();
        /**
         * @brief 写出 Nset
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-05-28
         */
        bool writeElement();
        /**
         * @brief 为了适配Assembly写出Orientation
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-07
         */
        bool writeOrientation();
        /**
         * @brief 写出材料方向
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-07
         */
        bool writeMaterialOrientation();
        /**
         * @brief 根据section是否写出材料方向
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-07
         */
        bool isWriteMaterialOrientation();
        /**
         * @brief 用于Assembly下的局部坐标系判断是否需要写出Orientation
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-07
         */
        bool isAssemblyJudgmentOrientationW(bool &ok);
        /**
         * @brief 用于Part下的局部坐标系判断是否需要写出Orientation
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-11
         */
        bool isPartJudgmentOrientationW(bool &ok);
        /**
         * @brief 写出Transform
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-05-28
         */
        bool writeTransform();
        /**
         * @brief 获取集合名称
         * @param transformId id
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-05-28
         */
        bool getElementName(int transformId);

    private:
        /**
         * @brief 算例数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-22
         */
        AbaqusData::FITKDataCase* _caseData{};
        /**
         * @brief 模型数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-22
         */
        Interface::FITKAbstractModel* _modelData{};
        /**
         * @brief 集合名称链表
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-05-28
         */
        QStringList _setNameList{};
        /**
         * @brief 是否是全局坐标系
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-07
         */
        bool _isGlobal{ false };
        /**
         * @brief 是否写出材料指派方向
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-11
         */
        bool _isMaterialOrientation{ false };
    };

    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaTransform, FITKAbaqusAdaptorTransform, 1)
    Register2FITKIOAdaptorFactory(INP, Interface::FITKCoordinateSystem, FITKAbaqusAdaptorTransform, 2)
    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaMaterialOrientation, FITKAbaqusAdaptorTransform, 3)
}

#endif
